package com.ruix.app.util;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.text.TextUtils;

import com.ruix.app.R;
import com.ruix.app.RuiApplication;
import com.ruix.app.constant.RuiXConstant;
import com.ruix.app.model.WXShare;
import com.tencent.mm.opensdk.modelmsg.SendMessageToWX;
import com.tencent.mm.opensdk.modelmsg.WXMediaMessage;
import com.tencent.mm.opensdk.modelmsg.WXWebpageObject;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
import com.umeng.socialize.ShareAction;
import com.umeng.socialize.UMShareListener;
import com.umeng.socialize.bean.SHARE_MEDIA;
import com.umeng.socialize.media.UMImage;
import com.umeng.socialize.media.UMWeb;

import java.io.ByteArrayOutputStream;

/**
 * Created by hadexs on 2017/5/3.
 */

public class ShareUtil {


    public static void shareToTimeline(Activity activity, String iamgeUrl,String webUrl, String title, String content, UMShareListener shareListener){
        UMImage image = new UMImage(activity, iamgeUrl);//网络图片
        UMWeb web = new UMWeb(webUrl);
        web.setTitle(title);   //标题
        web.setThumb(image);  //缩略图
        web.setDescription(content);//描述
        new ShareAction(activity).setPlatform(SHARE_MEDIA.WEIXIN)
                .withMedia(web)
                .withText(title)
                .setCallback(shareListener)
                .share();
    }


    public static void shareToSession(Activity activity, String iamgeUrl,String webUrl, String title, String content, UMShareListener shareListener){
        UMImage image = new UMImage(activity, iamgeUrl);//网络图片
        UMWeb web = new UMWeb(webUrl);
        web.setTitle(title);   //标题
        web.setThumb(image);  //缩略图
        web.setDescription(content);//描述
        new ShareAction(activity).setPlatform(SHARE_MEDIA.WEIXIN_CIRCLE)
                .withMedia(web)
                .withText(title)
                .setCallback(shareListener)
                .share();
    }





}
